package com.masterlau.entry;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import static com.masterlau.entry.Helper.DEF_SERVER_PORT;

/**
 * @author MasterLau
 */
final class Server implements Serializable {
    private static final long serialVersionUID = 1L;
    public String host;
    public int port = DEF_SERVER_PORT;
    public String username;
    public String password;
    public String uploadDir;
    public String executeDir;
    public String[] logPatterns;
    public List<String> logDirs = Collections.emptyList();

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final Server server = (Server) o;
        return port == server.port && Objects.equals(host, server.host) && Objects.equals(username, server.username) && Objects.equals(password, server.password) && Objects.equals(uploadDir, server.uploadDir) && Objects.equals(executeDir, server.executeDir) && Objects.equals(logDirs, server.logDirs) && Arrays.equals(logPatterns, server.logPatterns);
    }

    @Override
    public int hashCode() {
        int result = host != null ? host.hashCode() : 0;
        result = 31 * result + port;
        result = 31 * result + (username != null ? username.hashCode() : 0);
        result = 31 * result + (password != null ? password.hashCode() : 0);
        result = 31 * result + (uploadDir != null ? uploadDir.hashCode() : 0);
        result = 31 * result + (executeDir != null ? executeDir.hashCode() : 0);
        result = 31 * result + (logDirs != null ? logDirs.hashCode() : 0);
        return 31 * result + Arrays.hashCode(logPatterns);
    }
}
